<template>
	<view class="web">
		<view class="title">
			<!-- 导航 -->

			<!-- 导航 -->
			<view class="title_text">
				<view @click="checkState(item.value)" v-for="item in stateList" :key="item.value"
					:class="{checked:item.value==params.state}">{{item.label}}</view>

			</view>
		</view>
		<!-- 身体 -->
		<view class="body">
			<view v-for="(item,index) in list" :key="item.id" class="body_box">
				<view class="box_content">
					<view @click="toDetail(item.id)" class="box_t">
						{{item.content}}
					</view>
					<view class="box_img">
						<image @click="previewImage(imgItem.url,index)" v-for="imgItem in item.images" :key="imgItem.id"
							:src="imgBaseUrl+imgItem.url" mode="aspectFill"></image>

					</view>
					<view class="box_c">
						<text>{{item.address}}</text>
						<text>{{item.typename}}</text>
					</view>
					<view class="box_b">
						<view class="time">{{item.addtime}}</view>
						<view class="btn">
							<view class="btn_l">{{item.statename}}</view>
							<view v-if="item.state==1" class="btn_r">撤销s</view>
						</view>
					</view>
				</view>
			</view>

		</view>
		<!-- 身体 -->
	</view>
</template>

<script>
	import {
		IMAGE_URL
	} from '../../utils/config.js'
	import {
		getList
	} from '../../api/repairs.js'
	export default {
		data() {
			return {
				stateList: [{
					label: "未处理",
					value: 1
				}, {
					label: "已处理",
					value: 2
				}, 
				{
					label: "全部",
					value: 0
				}],
				imgBaseUrl: IMAGE_URL,
				params: {
					state: 0,
					page: 1,
					psize: 15
				},
				list: []
			}
		},
		onLoad() {
			this.getData();
		},
		methods: {
			checkState(val) {
				this.params.state = val;
				this.params.page = 1;
				this.getData();
			},
			toDetail(id) {
				uni.navigateTo({
					url: `/pages/repairs/detail?id=${id}`
				})

			},
			previewImage(current, index) {

				let urls = this.list[index].images.map(item => this.imgBaseUrl + item.url);
				uni.previewImage({
					current: this.imgBaseUrl + current,
					urls
				})
			},
			async getData() {
				const {
					errCode,
					data
				} = await getList(this.params);
				console.log(888, data);
				if (errCode === 10000) {
					this.list = data.list;
				}

			}
		}
	}
</script>

<style>
	@import url('../../static/css/Repair record.css');
</style>